/* 
 * File:   RapidHttpServletFactory.h
 * Author: dell
 *
 * Created on 2012年4月2日, 上午10:42
 */

#ifndef RAPIDHTTPSERVLETFACTORY_H
#define	RAPIDHTTPSERVLETFACTORY_H

#include <string>
#include "common.h"
#include "config/ServerConfig.h"

#include <evhttp/HttpServletFactory.h>
#include <evhttp/HttpServlet.h>
namespace Rapid{
    class RapidHttpServletFactory : public HttpServletFactory{
    public:
        RapidHttpServletFactory(ServerConfig* serverConfig);
        virtual ~RapidHttpServletFactory();

        virtual HttpServlet* create(const char* path);

        virtual void free(HttpServlet* servlet);

        
    protected:        
        /** 创建HttpServlet */
        virtual HttpServlet* servlet(ServerConfig* serverConfig, ContextConfig* contextConfig, const char* subpath);
        
        /** 当出错时创建的HttpServlet */
        virtual HttpServlet* error(unsigned short int code, const char* message);
        
    protected:
        ServerConfig* serverConfig;
        std::string root;
    };
}
#endif	/* RAPIDHTTPSERVLETFACTORY_H */

